﻿using System;

namespace AsyncEvtEcho
{
    sealed class BodyState : RecvStateBase
    {
        public BodyState(HeadBodyRecver context)
            : base(context)
        {
        }

        public byte[] Body { get { return m_buffer; } }

        #region [ override methods ]

        protected override bool End()
        {
            m_context.OnBodyReceived();
            return true;
        }

        public override int WholeLength
        {
            get { return m_buffer.Length; }
            set
            {
                if (m_buffer == null || m_buffer.Length != value)
                    m_buffer = new byte[value];
                m_readed = 0;
            }
        }

        #endregion
    }
}
